home *** CD-ROM | disk | FTP | other *** search
- Path: templar.fgi.net!bwendlin
- From: bwendlin@I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN (Physics Lizard)
- Newsgroups: comp.lang.c
- Subject: Re: HELP! Modifying the EOF in a file!
- Date: 13 Mar 1996 01:33:06 GMT
- Organization: FGInet, Inc., Springfield, IL
- Message-ID: <4i58ki$uoh@grail.fgi.net>
- References: <4i585k$4ia@news.netam.net>
- NNTP-Posting-Host: templar.fgi.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- The Bowling Green Connection inexplicably wrote:
- } I am having trouble shortening the size of a text file...
- } Suppose I have a text file with 3 lines of data, then I
- } run this program:
-
- } void main() {
- } FILE *dat;
- } dat=fopen("file.txt", "r+");
- } fprintf(dat, "Hello! %c", EOF);
- } fclose(dat);
- } }
-
- } Why doesn't the EOF character chop off the remaining two lines?
- } When I print out the file after running this program, the ONLY thing
- } that changed was the first few characters.. The other two lines
- } still remain.. HELP!
-
- You are opening the file read only. In order to do what you are
- wanting, why don't you just open the file as write? Then, everything
- in the file will be overwritten.
-
- --
- Bill Wendling bwendlin@fgi.net
- GCS/M/S d s-:+ a? C++++$ UL++>++++ P+++>+++++ L+++>+++++ E--- W-- N++ !o
- !K w--- O M-- !V PS+++@ PE- Y !PGP t+++(*) 5-- X- R++ tv--- b+++ DI++++
- !D G+ e++>+++++ h(++) !r !y+
-